﻿using JzSport.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Api
{
    class FeedbackActivityAction : AuthPostAction<Params.FeedbackActivityParams,
        Results.FeedbackActivityResult>
    {
        protected override ActionResult<Results.FeedbackActivityResult> OnExecute(ActionContext context, SysParameters sysParameters,
            Params.FeedbackActivityParams opParams)
        {
            ServiceResult<ActivityFeedback> serviceResult = new ActivityService().Feedback(context.AccountId,
                opParams.ActivityId,
                opParams.Content);

            Results.FeedbackActivityResult actionResult = new Results.FeedbackActivityResult();

            if (serviceResult.ErrorCode == ErrorCode.NoError)
            {
                return new ActionResult<Results.FeedbackActivityResult>("1.0.1", true, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
            }
            return new ActionResult<Results.FeedbackActivityResult>("1.0.1", false, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
        }
    }
}
